package org.hero.web;

import org.hero.dao.NewsDao;
import org.hero.dao.TelecomDAO;
import org.hero.entity.PageData;
import org.hero.entity.QunSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xuzhongyao on 2017/6/16.
 */
@Controller
public class TelecomController {

    @Autowired
    TelecomDAO telecomDAO;

    @Autowired
    NewsDao newsDao;


    @ResponseBody
    @RequestMapping("/selectTop7XiaoQu")
    public PageData selectTop7XiaoQu(ModelMap modelMap, String suggest) {

        PageData pd = new PageData();
        //查询流量排行前7的小区及数据
        List<PageData> list = telecomDAO.selectTop7XiaoQu(suggest);
        //查询故障小区数
        Long faildNum = telecomDAO.selectFaildXiaoQu(suggest);

        Long successNum = telecomDAO.selectXiaoQuTotal(suggest) - faildNum;

        if(successNum<=0){
            successNum = (long) 0;
        }

        List<QunSummary> list2 = newsDao.selectCake(suggest);
        pd.put("list",list);
        pd.put("list2",list2);
        pd.put("faildNum",faildNum);
        pd.put("successNum",successNum);
        return pd;
    }



}
